package com.shawn.mobliesafe;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;


public class LostfindActivity extends AppCompatActivity {

    private SharedPreferences sp;
    private TextView tv_lostfind_safenum;
    private ImageView tv_lostfind_protected;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        sp = getSharedPreferences("config",MODE_PRIVATE);
        if(sp.getBoolean("first",true)) {
            //第一次进入,跳转到手机防盗设置向导界面
            Intent intent = new Intent(this,SetUp1Activity.class);
            startActivity(intent);
            //移出lostfindActivity
            finish();
        }else {
            setContentView(R.layout.activity_lostfind);
            tv_lostfind_safenum = (TextView)findViewById(R.id.tv_lostfind_safenum);
            tv_lostfind_protected = (ImageView) findViewById(R.id.tv_lostfind_protected);
            String safenum = sp.getString("safenum","");
            if(!TextUtils.isEmpty(safenum)) {

                tv_lostfind_safenum.setText(safenum);
            }
            if(sp.getBoolean("protected",false)) {
                tv_lostfind_protected.setImageResource(R.mipmap.lock);
            }else {
                tv_lostfind_protected.setImageResource(R.mipmap.unlock);
            }
        }
    }

    public void resetup(View view) {
        Intent intent = new Intent(this,SetUp1Activity.class);
        startActivity(intent);
        finish();
    }
}
